package com.devilvan.betrice.europeacademy.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.europeacademy.mapper.EuropeAcademyAwardMapper;
import com.devilvan.betrice.europeacademy.po.EuropeAcademyAwardPo;
import com.devilvan.betrice.europeacademy.repository.EuropeAcademyAwardRepository;
import com.devilvan.betrice.europeacademy.service.EuropeAcademyAwardService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Evad.Wu
 * @Description 欧洲学术成员 奖项荣誉 业务逻辑类
 * @date 2022-09-06
 */
@Service
public class EuropeAcademyAwardServiceImpl extends ServiceImpl<EuropeAcademyAwardMapper, EuropeAcademyAwardPo> implements EuropeAcademyAwardService {
    @Resource(name = "europeAcademyAwardRepository")
    private EuropeAcademyAwardRepository repository;

    @Override
    public List<EuropeAcademyAwardPo> saveUpdateBatch(List<EuropeAcademyAwardPo> list) {
        return repository.saveAllAndFlush(list);
    }

    @Override
    public void deleteByMembershipId(Long membershipId) {
        LambdaUpdateWrapper<EuropeAcademyAwardPo> updateWrapper = new UpdateWrapper<EuropeAcademyAwardPo>().lambda();
        updateWrapper.eq(EuropeAcademyAwardPo::getMembershipId, membershipId);
        this.baseMapper.delete(updateWrapper);
    }
}
